<div class="bjui-pageContent">
    <div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
        <form data-toggle="ajaxsearch" data-options="{searchDatagrid:$.CurrentNavtab.find('#depart-user-lists-table')}">
            <fieldset>
                <legend style="font-weight:normal;">搜索：</legend>
                <div style="margin:0; padding:1px 5px 5px;">
                    <span>姓名：</span>
                    <input type="text" name="truename" class="form-control" size="20">
                    <span>手机号：</span>
                    <input type="text" name="mobile" class="form-control" size="20">
                    <span>部门：</span>
                    <select data-toggle="selectpicker" name="department_id">
                        <option value="">全部</option>
                        @foreach ($data['department_list'] as $val)
                            <option value="{{$val['id']}}">{{$val['title']}}</option>
                        @endforeach
                    </select>
                    <span>拥有权限：</span>
                    <select data-toggle="selectpicker" name="privilege_id">
                        <option value="">全部</option>
                        @foreach ($data['privilege_list'] as $val)
                            <option value="{{$val['id']}}">{{$val['title']}}</option>
                        @endforeach
                    </select>
                    <div class="btn-group">
                        <button type="submit" class="btn-green" data-icon="search">开始搜索</button>
                        <button type="reset" class="btn-orange" data-icon="times">重置</button>
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
    <table class="table table-bordered" id="depart-user-lists-table" data-toggle="datagrid" data-options="{
        tableWidth: '100%',
        height:'90%',
        gridTitle : '部门员工列表',
        showToolbar: true,
        toolbarItem: 'add,del',
        local: 'local',
        dataUrl: '/admin/company/depart-user-lists',
        delPK: 'id',
        linenumberAll: false,
        showLinenumber: false,
        showCheckboxcol: true,
        filterThead: false,
        showEditbtnscol: '操作',
        editUrl: '/admin/company/depart-user-edit',
        editCallback:editCallback,
        delUrl:'/admin/company/depart-user-delete',
        delConfirm: true,
        addLocation: 'first',
        fieldSortable: false,
        columnMenu: false,
    }">

        <thead>
        <tr>
            <th data-options="{name:'id',align:'center',width:50,edit:false,add:false}">编号</th>
            <th data-options="{name:'truename',align:'center'}">姓名</th>
            <th data-options="{name:'mobile',align:'center',edit:false}">手机号</th>
            <!--<th data-options="{name:'price',align:'center'}">计件工资(单件)</th>-->
            <th data-options="{name:'department_id',type:'select',items:{{$jsonData['department_list']}},align:'center'}">所属部门</th>
            <th data-options="{name:'is_leader',type:'select',items:[{0:'员工'},{1:'主管'}],align:'center'}">是否主管</th>
            <th data-options="{name:'privilege_id',type:'select',items:{{$jsonData['privilege_list']}},align:'center'}">拥有权限</th>
            <th data-options="{align:'center',render:customer_manage}">密码管理</th>
        </tr>
        </thead>
    </table>
</div>
<script>
    function customer_manage(value,data){
        var html = '<button type="button" class="btn-green" onclick="setPassword('+ data.id+');">修改密码</button>'
        return html

    }

    function setPassword(id){
        BJUI.alertmsg('prompt', '请输入新密码', {
        okCall: function(password) {
                if(password.length<6 || password.length>20){
                    BJUI.alertmsg('info', '密码应为6-20字符！')
                }
                else{
                    BJUI.ajax('doajax', {
                          url: '/admin/customer/set-password',
                          loadingmask: true,
                          data:{id:id,password:password},
                          okCallback: function(json, options) {

                          }
                    })
                }
            }
        });
    }
</script>